Attribute VB_Name = "modDataFuncs"
Global conLocal As ADODB.Connection

Public Sub CloseRS(rsX As ADODB.Recordset)
    On Error Resume Next
    If Not rsX Is Nothing Then
        If rsX.State <> 0 Then rsX.Close
        Set rsX = Nothing
    End If
    Err.Clear
End Sub

Public Function OpenLocalConnection() As Boolean
On Error GoTo Errorhandler
    
    
    If conLocal Is Nothing Then
        Set conLocal = New ADODB.Connection
    End If
    If conLocal.State <> 1 Then
        'FOR ACCESS

        'conLocal.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & _
             App.Path & "\IPSRF4.mdb;User ID=Admin;Password=;"
             conLocal.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\SynRF.mdb;"
        'conLocal.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\SynRF.mdb;"
        'FOR SQL
        'conLocal.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=YCE;Data Source=HM-2003"

    End If
    OpenLocalConnection = True
   
    Exit Function
Errorhandler:
    OpenLocalConnection = False
    Err.Clear
End Function

Public Function CloseLocalConnection() As Boolean
    If Not conLocal Is Nothing Then
        If conLocal.State <> 0 Then conLocal.Close
        Set conLocal = Nothing
    End If
    CloseLocalConnection = True
End Function

Sub execSql(strSql As String)
On Error GoTo ErrHandle

    Dim sqlCmd As New ADODB.Command
    
    'sqlCmd.CommandType = adCmdStoredProc
    sqlCmd.CommandText = strSql
    sqlCmd.ActiveConnection = MDIForm1.dc.conDynamic
    sqlCmd.Execute

ErrHandle:

End Sub

' *********************************************************************
' FUNCTION: CDate2Julian()
'
' PURPOSE: Convert a date to a Julian day. The function works with
'          dates based on the Gregorian (modern) calendar.
'
' ARGUMENTS:
'    MyDate: A valid Microsoft Access date.
'
' RETURNS: A three digit Julian day as a string.
' *********************************************************************

Function CDate2Julian(MyDate As Date) As String

   CDate2Julian = Format(MyDate - DateSerial(Year(MyDate) - 1, 12, _
     31), "000")

End Function


